package com.atguigu.product.controller;

import com.atguigu.product.bean.Product;
import com.atguigu.product.service.ProductService;
import jakarta.websocket.server.PathParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.TimeUnit;
// 允许跨域
//@CrossOrigin
//@RequestMapping("/api/product")
@RestController
public class ProductController {

    @Autowired
    ProductService productService;
    @GetMapping("/product/{id}")
    //查询商品
    public Product getProduct(@PathVariable("id") Long productId) {
        Product product = productService.getProductById(productId);
//        try {
//            TimeUnit.SECONDS.sleep(2);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
        System.out.println("执行了");
        return product;
    }
}
